//
//  UISwitchViewController.swift
//  Example
//
//  Created by T AO on 2022/2/15.
//

import UIKit
import RxCocoa
import RxSwift

class UISwitchViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        switchRx()
    }

}

// MARK: - UISwitch

extension UISwitchViewController {
    private func switchRx() {
        let s = UISwitch(frame: CGRect(x: 50, y: 100, width: 50, height: 50))
        view.addSubview(s)
        
        s.rx.isOn
            .asObservable()
            .subscribe(onNext: { print("当前开关状态：\($0)") })
            .disposed(by: disposeBag)
    }
}
